<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../../css/api.css">
    <link rel="stylesheet" type="text/css" href="../../css/aui.css">
    <link rel="stylesheet" type="text/css" href="../../css/button.css">
    <style type="text/css">
        #tab1 {
            position: relative;
            background-color: #03a9f5;
            display: -webkit-box;
            display: -webkit-flex;
            display: flex;
            -webkit-flex-wrap: nowrap;
            flex-wrap: nowrap;
            -webkit-align-self: center;
            align-self: center;
        }

        .active {
            border-bottom: 4px solid #ff5f43;
        }

        .tab {
            width: 100%;
            height: 2.2rem;
            line-height: 2.2rem;
            position: relative;
            font-size: 0.7rem;
            text-align: center;
            color: #f8fdff;
            margin-left: -1px;
            -webkit-box-flex: 1;
            box-flex: 1;
        }

        .item {
            position: relative;
            font-size: 0.7rem;
            color: #212121;
            top: 50%;
            margin: auto auto;
            text-align: center;
            font-size: 16px;
        }
    </style>
</head>

<body>
    <div id="tab1">
        <div id="tb0" class="tab tapmode active" onclick="randomSwitchBtn(this)">2015</div>
        <div id="tb1" class="tab tapmode" onclick="randomSwitchBtn(this)">2016</div>
        <div id="tb2" class="tab tapmode" onclick="randomSwitchBtn(this)">2017</div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
    apiready = function() {
        funIniGroup();
    };
    var tab1 = $api.dom("#tab1");
    var list = $api.dom("#list");
    var count = 3; //3个界面
    var activeIndex = 0;
    var tit = ["2015", "2016", "2017"];

    function randomSwitchBtn(tag) {

    }

    function funIniGroup() {
        var frames = [];
        for (var i = 0; i < count; ++i) {
            frames.push({
                name: 'today_2015_frm' + i,
                url: 'today_frm' + i + '.html',
                bgColor: 'rgba(0,0,0,.2)',
                bounces: false
            });
        }

        api.openFrameGroup({
            name: 'today_group',
            rect: {
                x: 0,
                y: api.pageParam['height1'] + tab1.offsetHeight,
                w: 'auto',
                h: api.winHeight - api.pageParam['height1'] - tab1.offsetHeight - api.pageParam['height2'],
                y: api.pageParam['height1'] + tab1.offsetHeight ,
                w: 'auto',
                h: api.winHeight - api.pageParam['height1'] - tab1.offsetHeight - api.pageParam['height2'],
            },
            frames: frames
        }, function(ret, err) {
            if (ret) {
                var index = ret.index;
                if (index == activeIndex) return;
                $("#tb" + index).toggleClass("active");
                $("#tb" + activeIndex).removeClass("active");
                activeIndex = index;
            }
        });
    }


    // 随意切换按钮
    function randomSwitchBtn(tag) {

        var index = tag.id.charAt(tag.id.length - 1);

        if (index == activeIndex) return;
        $("#tb" + index).toggleClass("active");
        $("#tb" + activeIndex).removeClass("active");
        activeIndex = index;
        api.setFrameGroupIndex({
            name: 'today_group',
            index: index
        });


    }
</script>

</html>
